package co.com.travelsoft.ati.daos;

import java.util.List;

import org.hibernate.Session;

import co.com.travelsoft.ati.entities.Paises;
import co.com.travelsoft.ati.utils.FabricaSesionesUtil;

public class PaisesDAO {
	
	public static void crear(Paises paises){
		Session s = FabricaSesionesUtil.getInstancia().getCurrentSession();
		s.save(paises);
	}
	
	public static Paises buscarPorId(Paises paises){
		Session s = FabricaSesionesUtil.getInstancia().getCurrentSession();
		return  (Paises)s.createQuery("select c from Paises as c where c.codigo="+paises.getCodigo()).uniqueResult();
	}
	
	public static List<Paises> listar(){
		Session s = FabricaSesionesUtil.getInstancia().getCurrentSession();
		return s.createQuery("select c from Paises as c").list();
	}
	
	public static void actualizar(Paises paises){
		Session s = FabricaSesionesUtil.getInstancia().getCurrentSession();
		s.update(paises);
	}
	
	public static void borrar(Paises paises){
		Session s = FabricaSesionesUtil.getInstancia().getCurrentSession();
		s.delete(paises);
	}

}
